{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# UpstageDocumentParseReader\n",
    "\n",
    "This notebook covers how to get started with `UpstageDocumentParseReader`.\n",
    "\n",
    "## Installation\n",
    "Please install `llama_index` package.\n",
    "```bash\n",
    "pip install llama-index-readers-upstage\n",
    "```\n",
    "\n",
    "## Environment Setup\n",
    "Make sure to set the following environment variables:\n",
    "- `UPSTAGE_API_KEY`: Your Upstage API key. Read [Upstage console](https://console.upstage.ai/) to get your API key."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Usage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "os.environ[\"UPSTAGE_API_KEY\"] = \"YOUR_API_KEY\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Doc ID: c7dbc90d-7ffe-4da8-bb25-2617a7224bf9\n",
      "Text: <p id='0' style='font-size:20px'>SOLAR 10.7B: Scaling Large\n",
      "Language Models with Simple yet Effective<br>Depth Up-Scaling</p>\n",
      "Doc ID: 7fe77a89-d43c-4e64-8bc5-78f6a8711530\n",
      "Text: <br><p id='1' style='font-size:18px'>Dahyun Kim ∗ , Chanjun Park\n",
      "∗† , Sanghoon Kim ∗† , Wonsung Lee ∗† , Wonho Song ∗<br>Yunsu Kim ∗ ,\n",
      "Hyeonwoo Kim ∗ , Yungi Kim, Hyeonju Lee, Jihoo Kim<br>Changbae Ahn,\n",
      "Seonghoon Yang, Sukyung Lee, Hyunbyung Park, Gyoungjin Gim<br>Mikyoung\n",
      "Cha, Hwalsuk Lee † , Sunghun Kim †</p>\n",
      "Doc ID: 12276f2e-63c0-45a8-8aa8-95210f5afc7d\n",
      "Text: <br><p id='2' style='font-size:18px'>Upstage AI, South Korea</p>\n"
     ]
    }
   ],
   "source": [
    "from llama_index.readers.upstage import UpstageDocumentParseReader\n",
    "\n",
    "file_path = \"/PATH/TO/YOUR/FILE.pdf\"\n",
    "\n",
    "reader = UpstageDocumentParseReader()\n",
    "\n",
    "# For improved memory efficiency, consider using the lazy_load method to load documents page by page.\n",
    "docs = reader.load_data(file_path=file_path, split=\"element\")\n",
    "\n",
    "for doc in docs[:3]:\n",
    "    print(doc)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "llama_upstage",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
